

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>HtmlWeaver - LiterateCS</title>

	<link rel="icon" type="image/x-icon" href="../images/favicon.ico">
    <link rel="stylesheet" href="../bootstrap/css/readable/bootstrap.min.css" />
<link rel="stylesheet" href="../font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="../sidebar/sidebar.min.css" />
<link rel="stylesheet" href="../css/book.min.css" />
<link rel="stylesheet" href="../syntax-highlight/solarized-light.min.css" />
<link rel="stylesheet" href="../mermaid/mermaid.css" />

</head>

<body>
    
    <nav class="navbar navbar-inverse navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#sidebar-toggle" id="sidebar-toggle">
					<span>
						<img src="../images/favicon.ico" height="24" class="hidden-sm hidden-xs" />
						<i id="sidebar-toggle-icon" class="hidden-md hidden-lg hidden-xl fa fa-angle-double-right" aria-hidden="true"></i>
						LiterateCS
					</span>
				</a>
            </div>
            <div id="navbar" class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                    <li><a href="../index.html"><i class="fa fa-home" aria-hidden="true"></i> Home</a></li>
					<li><a href="https://github.com/johtela/LiterateCS"><i class="fa fa-github" aria-hidden="true"></i> GitHub Repository</a></li>
                    <li><a href="https://www.nuget.org/packages/LiterateCS/"><i class="fa fa-download" aria-hidden="true"></i> Download</a></li>
                    <li><a href="../License.html">License</a></li>
                </ul>
            </div>
        </div>
    </nav>

    <div class="container">
        <div class="row">
            <div id="sidebar" class="col-md-3 hidden-sm hidden-xs">
                
        <div class="panel panel-default">
            <div class="panel-heading">
                <h4>On This Page</h4>
            </div>
            <div id="header-menu" class="panel-body main-menu">
                <ul></ul>
            </div>
        </div>  
        <div class="panel panel-default">
            <div class="panel-heading">
                <h4>Table of Contents</h4>
            </div>
            <div class="panel-body main-menu">
                <ul>
	<li><a href="../index.html">Home</a></li>
	<ul>
	</ul>
	<li><a href="../Introduction.html">Introduction</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/Options.html">Command Line Options</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/Program.html">Main Program</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/SplitPath.html">SplitPath Structure</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/Weaver.html">Document Weaver</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/MdWeaver.html">Markdown Weaver</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/HtmlWeaver.html" class="selected">HTML Weaver</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/TocManager.html">TOC Manager</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/BlockList.html">Source Blocks</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/Macro.html">Macros</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/BlockBuilder.html">Block Builder</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/HtmlBlockBuilder.html">HTML Block Builder</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/HtmlGenerator.html">HTML Generation</a></li>
	<ul>
	</ul>
	<li>Themes</li>
	<ul>
<ul>
	<li><a href="../LiterateCS.Theme/DirHelpers.html">Directory Utilities</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS.Theme/Toc.html">Table of Contents Classes</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS.Theme/PageParams.html">Page Parameters</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS.Theme/Theme.html">Theme Base Class</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS.Theme/LiterateException.html">Reporting Errors</a></li>
	<ul>
	</ul>
</ul>
	</ul>
	<li><a href="../FrontMatter.html">Front Matter</a></li>
	<ul>
	</ul>
	<li><a href="../TableOfContents.html">Table of Contents File</a></li>
	<ul>
	</ul>
	<li><a href="../TipsAndTricks.html">Tips &amp; Tricks</a></li>
	<ul>
	</ul>
	<li><a href="../License.html">License</a></li>
	<ul>
	</ul>
	<li><a href="../README.html">README</a></li>
	<ul>
	</ul>
	<li><a href="../Installation.html">Installation</a></li>
	<ul>
	</ul>
</ul>
            </div>
        </div>

            </div>
			<div id="contentarea" class="col-md-9 col-sm-12 col-sm-push-0 col-xs-12 col-xs-push-0">
				<ul class="pager">
	<li class="previous"><a href="../LiterateCS/MdWeaver.html">Previous: Markdown Weaver</a></li>
	<li class="next"><a href="../LiterateCS/TocManager.html">Next: TOC Manager</a></li>
</ul>
				<div id="static-content" class="markdown">
					<h1 id="html-weaver">HTML Weaver</h1>
<p>On high level, weaving source files into web pages resembles the markdown
generation process. The biggest difference is that HTML weaver has to manage
the table of contents when working with input files. Also, two special classes
are used to produce the actual HTML output:</p>
<ul>
<li><a href="HtmlBlockBuilder.html">HtmlBlockBuilder</a> which decorates the code blocks
with styling information.</li>
<li><a href="HtmlGenerator.html">HtmlGenerator</a> which converts the markdown to HTML, and loads
the theme assembly, which in turn renders the HTML into a fully functional website.</li>
</ul>
<p>But first, let's focus on how the source files are processed when HTML output is
selected.</p>
<pre class="csharp"><code class="csharp"><span class="keyword" id="LiterateCS">namespace</span> LiterateCS
<span class="punctuation">{</span>
	<span class="keyword">using</span> Microsoft<span class="punctuation">.</span>CodeAnalysis<span class="punctuation">;</span>
	<span class="keyword">using</span> System<span class="punctuation">.</span>IO<span class="punctuation">;</span>

	<span class="keyword" id="LiterateCS.HtmlWeaver">public</span> <span class="keyword">class</span> <span class="typename">HtmlWeaver</span> <span class="punctuation">:</span> <span class="typename" data-toggle="tooltip" title="LiterateCS.Weaver"><a href="../LiterateCS/Weaver.html#LiterateCS.Weaver">Weaver</a></span>
	<span class="punctuation">{</span>
</code></pre>
<h2 id="initialization">Initialization</h2>
<p>Constructor loads the TOC manager and creates the HTML generator. After that,
it loads the default settings.</p>
<pre class="csharp"><code class="csharp">		<span class="keyword">private</span> <span class="typename" data-toggle="tooltip" title="LiterateCS.HtmlGenerator"><a href="../LiterateCS/HtmlGenerator.html#LiterateCS.HtmlGenerator">HtmlGenerator</a></span> <span id="LiterateCS.HtmlWeaver._generateHtml">_generateHtml</span><span class="punctuation">;</span>
		<span class="keyword">protected</span> <span class="typename" data-toggle="tooltip" title="LiterateCS.TocManager"><a href="../LiterateCS/TocManager.html#LiterateCS.TocManager">TocManager</a></span> <span id="LiterateCS.HtmlWeaver._tocManager">_tocManager</span><span class="punctuation">;</span>

		<span class="keyword" id="LiterateCS.HtmlWeaver.HtmlWeaver(LiterateCS.Options)" data-toggle="tooltip" title="LiterateCS.HtmlWeaver.HtmlWeaver(LiterateCS.Options)">public</span> <span data-toggle="tooltip" title="LiterateCS.HtmlWeaver.HtmlWeaver(LiterateCS.Options)">HtmlWeaver</span> <span class="punctuation">(</span><span class="typename" data-toggle="tooltip" title="LiterateCS.Options"><a href="../LiterateCS/Options.html#LiterateCS.Options">Options</a></span> options<span class="punctuation">)</span>
			<span class="punctuation" data-toggle="tooltip" title="void">:</span> <span class="keyword" data-toggle="tooltip" title="void">base</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="LiterateCS.Options">options</span><span class="punctuation">)</span> 
		<span class="punctuation">{</span>
			<span data-toggle="tooltip" title="LiterateCS.HtmlWeaver.LoadToc()"><a href="../LiterateCS/HtmlWeaver.html#LiterateCS.HtmlWeaver.LoadToc()">LoadToc</a></span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
			<span data-toggle="tooltip" title="LiterateCS.HtmlGenerator"><a href="../LiterateCS/HtmlWeaver.html#LiterateCS.HtmlWeaver._generateHtml">_generateHtml</a></span> <span class="punctuation" data-toggle="tooltip" title="LiterateCS.HtmlGenerator">=</span> <span class="keyword" data-toggle="tooltip" title="LiterateCS.HtmlGenerator">new</span> <span class="typename"><a href="../LiterateCS/HtmlGenerator.html#LiterateCS.HtmlGenerator">HtmlGenerator</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="LiterateCS.Options"><a href="../LiterateCS/Weaver.html#LiterateCS.Weaver._options">_options</a></span><span class="punctuation">,</span> <span data-toggle="tooltip" title="LiterateCS.TocManager"><a href="../LiterateCS/HtmlWeaver.html#LiterateCS.HtmlWeaver._tocManager">_tocManager</a></span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.Theme.Toc">.</span><span data-toggle="tooltip" title="LiterateCS.Theme.Toc"><a href="../LiterateCS/TocManager.html#LiterateCS.TocManager.Toc">Toc</a></span><span class="punctuation">)</span><span class="punctuation">;</span>
			<span data-toggle="tooltip" title="LiterateCS.HtmlWeaver.LoadDefaultFrontMatter()"><a href="../LiterateCS/HtmlWeaver.html#LiterateCS.HtmlWeaver.LoadDefaultFrontMatter()">LoadDefaultFrontMatter</a></span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
		<span class="punctuation">}</span>
</code></pre>
<p>A customized version of BlockBuilder is employed by overriding the virtual
method that creates it.</p>
<pre class="csharp"><code class="csharp">		<span class="keyword" id="LiterateCS.HtmlWeaver.CreateBlockBuilder()" data-toggle="tooltip" title="LiterateCS.HtmlWeaver.CreateBlockBuilder()">protected</span> <span class="keyword" data-toggle="tooltip" title="LiterateCS.HtmlWeaver.CreateBlockBuilder()">override</span> <span class="typename" data-toggle="tooltip" title="LiterateCS.BlockBuilder"><a href="../LiterateCS/BlockBuilder.html#LiterateCS.BlockBuilder">BlockBuilder</a></span> <span data-toggle="tooltip" title="LiterateCS.HtmlWeaver.CreateBlockBuilder()">CreateBlockBuilder</span> <span class="punctuation">(</span><span class="punctuation">)</span>
		<span class="punctuation">{</span>
			<span class="keyword">return</span> <span class="keyword" data-toggle="tooltip" title="LiterateCS.HtmlBlockBuilder">new</span> <span class="typename"><a href="../LiterateCS/HtmlBlockBuilder.html#LiterateCS.HtmlBlockBuilder">HtmlBlockBuilder</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="LiterateCS.Options"><a href="../LiterateCS/Weaver.html#LiterateCS.Weaver._options">_options</a></span><span class="punctuation">)</span><span class="punctuation">;</span>
		<span class="punctuation">}</span>
</code></pre>
<p>Generation methods process the input files and update the TOC while
looping through them. Finally they copy the auxiliary files (CSS,
Javascript, fonts, etc.) that are required by the generated HTML
files. Auxiliary files reside in a theme assembly, and themes are
responsible for copying them to the output folder. The weaver just
invokes the copy method through the HTML generator object.</p>
<pre class="csharp"><code class="csharp">		<span class="keyword" id="LiterateCS.HtmlWeaver.GenerateFromFiles()" data-toggle="tooltip" title="LiterateCS.HtmlWeaver.GenerateFromFiles()">protected</span> <span class="keyword" data-toggle="tooltip" title="LiterateCS.HtmlWeaver.GenerateFromFiles()">override</span> <span class="keyword" data-toggle="tooltip" title="void">void</span> <span data-toggle="tooltip" title="LiterateCS.HtmlWeaver.GenerateFromFiles()">GenerateFromFiles</span> <span class="punctuation">(</span><span class="punctuation">)</span>
		<span class="punctuation">{</span>
			<span class="keyword">foreach</span> <span class="punctuation">(</span><span class="keyword" data-toggle="tooltip" title="LiterateCS.SplitPath">var</span> file <span class="keyword">in</span> <span data-toggle="tooltip" title="LiterateCS.Weaver.SourceFiles()"><a href="../LiterateCS/Weaver.html#LiterateCS.Weaver.SourceFiles()">SourceFiles</a></span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">)</span>
			<span class="punctuation">{</span>
				<span data-toggle="tooltip" title="LiterateCS.HtmlWeaver.WeaveFromCodeFile(LiterateCS.SplitPath)"><a href="../LiterateCS/HtmlWeaver.html#LiterateCS.HtmlWeaver.WeaveFromCodeFile(LiterateCS.SplitPath)">WeaveFromCodeFile</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="LiterateCS.SplitPath">file</span><span class="punctuation">)</span><span class="punctuation">;</span>
				<span data-toggle="tooltip" title="LiterateCS.HtmlWeaver.AddToToc(LiterateCS.SplitPath)"><a href="../LiterateCS/HtmlWeaver.html#LiterateCS.HtmlWeaver.AddToToc(LiterateCS.SplitPath)">AddToToc</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="LiterateCS.SplitPath">file</span><span class="punctuation">)</span><span class="punctuation">;</span>
			<span class="punctuation">}</span>
			<span class="keyword">foreach</span> <span class="punctuation">(</span><span class="keyword" data-toggle="tooltip" title="LiterateCS.SplitPath">var</span> file <span class="keyword">in</span> <span data-toggle="tooltip" title="LiterateCS.Weaver.MarkdownFiles()"><a href="../LiterateCS/Weaver.html#LiterateCS.Weaver.MarkdownFiles()">MarkdownFiles</a></span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">)</span>
			<span class="punctuation">{</span>
				<span data-toggle="tooltip" title="LiterateCS.HtmlWeaver.WeaveFromMarkdown(LiterateCS.SplitPath)"><a href="../LiterateCS/HtmlWeaver.html#LiterateCS.HtmlWeaver.WeaveFromMarkdown(LiterateCS.SplitPath)">WeaveFromMarkdown</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="LiterateCS.SplitPath">file</span><span class="punctuation">)</span><span class="punctuation">;</span>
				<span data-toggle="tooltip" title="LiterateCS.HtmlWeaver.AddToToc(LiterateCS.SplitPath)"><a href="../LiterateCS/HtmlWeaver.html#LiterateCS.HtmlWeaver.AddToToc(LiterateCS.SplitPath)">AddToToc</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="LiterateCS.SplitPath">file</span><span class="punctuation">)</span><span class="punctuation">;</span>
			<span class="punctuation">}</span>
			<span data-toggle="tooltip" title="LiterateCS.Weaver.ConsoleOut(string, params object[])"><a href="../LiterateCS/Weaver.html#LiterateCS.Weaver.ConsoleOut(string, object[])">ConsoleOut</a></span> <span class="punctuation">(</span><span class="string" data-toggle="tooltip" title="string">&quot;Copying auxiliary HTML files...&quot;</span><span class="punctuation">)</span><span class="punctuation">;</span>
			<span data-toggle="tooltip" title="LiterateCS.HtmlGenerator"><a href="../LiterateCS/HtmlWeaver.html#LiterateCS.HtmlWeaver._generateHtml">_generateHtml</a></span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.HtmlGenerator.CopyAuxiliaryFiles()">.</span><span data-toggle="tooltip" title="LiterateCS.HtmlGenerator.CopyAuxiliaryFiles()"><a href="../LiterateCS/HtmlGenerator.html#LiterateCS.HtmlGenerator.CopyAuxiliaryFiles()">CopyAuxiliaryFiles</a></span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
			<span data-toggle="tooltip" title="LiterateCS.TocManager"><a href="../LiterateCS/HtmlWeaver.html#LiterateCS.HtmlWeaver._tocManager">_tocManager</a></span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.TocManager.Save()">.</span><span data-toggle="tooltip" title="LiterateCS.TocManager.Save()"><a href="../LiterateCS/TocManager.html#LiterateCS.TocManager.Save()">Save</a></span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
		<span class="punctuation">}</span>

		<span class="keyword" id="LiterateCS.HtmlWeaver.GenerateFromSolution()" data-toggle="tooltip" title="LiterateCS.HtmlWeaver.GenerateFromSolution()">protected</span> <span class="keyword" data-toggle="tooltip" title="LiterateCS.HtmlWeaver.GenerateFromSolution()">override</span> <span class="keyword" data-toggle="tooltip" title="void">void</span> <span data-toggle="tooltip" title="LiterateCS.HtmlWeaver.GenerateFromSolution()">GenerateFromSolution</span> <span class="punctuation">(</span><span class="punctuation">)</span>
		<span class="punctuation">{</span>
			<span class="keyword">foreach</span> <span class="punctuation">(</span><span class="keyword" data-toggle="tooltip" title="System.Tuple<LiterateCS.SplitPath, Microsoft.CodeAnalysis.Document>">var</span> doc <span class="keyword">in</span> <span data-toggle="tooltip" title="LiterateCS.Weaver.CSharpDocumentsInSolution()"><a href="../LiterateCS/Weaver.html#LiterateCS.Weaver.CSharpDocumentsInSolution()">CSharpDocumentsInSolution</a></span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">)</span>
			<span class="punctuation">{</span>
				<span data-toggle="tooltip" title="LiterateCS.HtmlWeaver.WeaveFromCSharpDocument(LiterateCS.SplitPath, Microsoft.CodeAnalysis.Document)"><a href="../LiterateCS/HtmlWeaver.html#LiterateCS.HtmlWeaver.WeaveFromCSharpDocument(LiterateCS.SplitPath, Microsoft.CodeAnalysis.Document)">WeaveFromCSharpDocument</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="System.Tuple<LiterateCS.SplitPath, Microsoft.CodeAnalysis.Document>">doc</span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.SplitPath">.</span><span data-toggle="tooltip" title="LiterateCS.SplitPath">Item1</span><span class="punctuation">,</span> <span data-toggle="tooltip" title="System.Tuple<LiterateCS.SplitPath, Microsoft.CodeAnalysis.Document>">doc</span><span class="punctuation" data-toggle="tooltip" title="Microsoft.CodeAnalysis.Document">.</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.Document">Item2</span><span class="punctuation">)</span><span class="punctuation">;</span>
				<span data-toggle="tooltip" title="LiterateCS.HtmlWeaver.AddToToc(LiterateCS.SplitPath)"><a href="../LiterateCS/HtmlWeaver.html#LiterateCS.HtmlWeaver.AddToToc(LiterateCS.SplitPath)">AddToToc</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="System.Tuple<LiterateCS.SplitPath, Microsoft.CodeAnalysis.Document>">doc</span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.SplitPath">.</span><span data-toggle="tooltip" title="LiterateCS.SplitPath">Item1</span><span class="punctuation">)</span><span class="punctuation">;</span>
			<span class="punctuation">}</span>
			<span class="keyword">foreach</span> <span class="punctuation">(</span><span class="keyword" data-toggle="tooltip" title="LiterateCS.SplitPath">var</span> inputFile <span class="keyword">in</span> <span data-toggle="tooltip" title="LiterateCS.Weaver.MarkdownFiles()"><a href="../LiterateCS/Weaver.html#LiterateCS.Weaver.MarkdownFiles()">MarkdownFiles</a></span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">)</span>
			<span class="punctuation">{</span>
				<span data-toggle="tooltip" title="LiterateCS.HtmlWeaver.WeaveFromMarkdown(LiterateCS.SplitPath)"><a href="../LiterateCS/HtmlWeaver.html#LiterateCS.HtmlWeaver.WeaveFromMarkdown(LiterateCS.SplitPath)">WeaveFromMarkdown</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="LiterateCS.SplitPath">inputFile</span><span class="punctuation">)</span><span class="punctuation">;</span>
				<span data-toggle="tooltip" title="LiterateCS.HtmlWeaver.AddToToc(LiterateCS.SplitPath)"><a href="../LiterateCS/HtmlWeaver.html#LiterateCS.HtmlWeaver.AddToToc(LiterateCS.SplitPath)">AddToToc</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="LiterateCS.SplitPath">inputFile</span><span class="punctuation">)</span><span class="punctuation">;</span>
			<span class="punctuation">}</span>
			<span data-toggle="tooltip" title="LiterateCS.Weaver.ConsoleOut(string, params object[])"><a href="../LiterateCS/Weaver.html#LiterateCS.Weaver.ConsoleOut(string, object[])">ConsoleOut</a></span> <span class="punctuation">(</span><span class="string" data-toggle="tooltip" title="string">&quot;Copying auxiliary HTML files...&quot;</span><span class="punctuation">)</span><span class="punctuation">;</span>
			<span data-toggle="tooltip" title="LiterateCS.HtmlGenerator"><a href="../LiterateCS/HtmlWeaver.html#LiterateCS.HtmlWeaver._generateHtml">_generateHtml</a></span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.HtmlGenerator.CopyAuxiliaryFiles()">.</span><span data-toggle="tooltip" title="LiterateCS.HtmlGenerator.CopyAuxiliaryFiles()"><a href="../LiterateCS/HtmlGenerator.html#LiterateCS.HtmlGenerator.CopyAuxiliaryFiles()">CopyAuxiliaryFiles</a></span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
			<span data-toggle="tooltip" title="LiterateCS.TocManager"><a href="../LiterateCS/HtmlWeaver.html#LiterateCS.HtmlWeaver._tocManager">_tocManager</a></span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.TocManager.Save()">.</span><span data-toggle="tooltip" title="LiterateCS.TocManager.Save()"><a href="../LiterateCS/TocManager.html#LiterateCS.TocManager.Save()">Save</a></span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
		<span class="punctuation">}</span>
</code></pre>
<p>The rest of the methods are helper functions that process a single file
at a time; first they split it to blocks, and then call HTMLGenerator
to convert it to a HTML page.</p>
<pre class="csharp"><code class="csharp">		<span class="keyword" id="LiterateCS.HtmlWeaver.WeaveFromCodeFile(LiterateCS.SplitPath)" data-toggle="tooltip" title="LiterateCS.HtmlWeaver.WeaveFromCodeFile(LiterateCS.SplitPath)">private</span> <span class="keyword" data-toggle="tooltip" title="void">void</span> <span data-toggle="tooltip" title="LiterateCS.HtmlWeaver.WeaveFromCodeFile(LiterateCS.SplitPath)">WeaveFromCodeFile</span> <span class="punctuation">(</span><span class="typename" data-toggle="tooltip" title="LiterateCS.SplitPath"><a href="../LiterateCS/SplitPath.html#LiterateCS.SplitPath">SplitPath</a></span> codeFile<span class="punctuation">)</span>
		<span class="punctuation">{</span>
			<span data-toggle="tooltip" title="LiterateCS.HtmlGenerator"><a href="../LiterateCS/HtmlWeaver.html#LiterateCS.HtmlWeaver._generateHtml">_generateHtml</a></span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.HtmlGenerator.Execute(LiterateCS.BlockList, LiterateCS.SplitPath, LiterateCS.SplitPath)">.</span><span data-toggle="tooltip" title="LiterateCS.HtmlGenerator.Execute(LiterateCS.BlockList, LiterateCS.SplitPath, LiterateCS.SplitPath)"><a href="../LiterateCS/HtmlGenerator.html#LiterateCS.HtmlGenerator.Execute(LiterateCS.BlockList, LiterateCS.SplitPath, LiterateCS.SplitPath)">Execute</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="LiterateCS.Weaver.BlockListFromCode(string)"><a href="../LiterateCS/Weaver.html#LiterateCS.Weaver.BlockListFromCode(string)">BlockListFromCode</a></span> <span class="punctuation">(</span><span class="punctuation" data-toggle="tooltip" title="string">!</span><span data-toggle="tooltip" title="LiterateCS.SplitPath">codeFile</span><span class="punctuation">)</span><span class="punctuation">,</span> <span data-toggle="tooltip" title="LiterateCS.SplitPath">codeFile</span><span class="punctuation">,</span> 
				<span data-toggle="tooltip" title="LiterateCS.Weaver.CreateOutputPath(LiterateCS.SplitPath, string)"><a href="../LiterateCS/Weaver.html#LiterateCS.Weaver.CreateOutputPath(LiterateCS.SplitPath, string)">CreateOutputPath</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="LiterateCS.SplitPath">codeFile</span><span class="punctuation">,</span> <span class="string" data-toggle="tooltip" title="string">&quot;.html&quot;</span><span class="punctuation">)</span><span class="punctuation">)</span><span class="punctuation">;</span>
		<span class="punctuation">}</span>

		<span class="keyword" id="LiterateCS.HtmlWeaver.WeaveFromCSharpDocument(LiterateCS.SplitPath, Microsoft.CodeAnalysis.Document)" data-toggle="tooltip" title="LiterateCS.HtmlWeaver.WeaveFromCSharpDocument(LiterateCS.SplitPath, Microsoft.CodeAnalysis.Document)">private</span> <span class="keyword" data-toggle="tooltip" title="void">void</span> <span data-toggle="tooltip" title="LiterateCS.HtmlWeaver.WeaveFromCSharpDocument(LiterateCS.SplitPath, Microsoft.CodeAnalysis.Document)">WeaveFromCSharpDocument</span> <span class="punctuation">(</span><span class="typename" data-toggle="tooltip" title="LiterateCS.SplitPath"><a href="../LiterateCS/SplitPath.html#LiterateCS.SplitPath">SplitPath</a></span> codeFile<span class="punctuation">,</span> <span class="typename" data-toggle="tooltip" title="Microsoft.CodeAnalysis.Document">Document</span> document<span class="punctuation">)</span>
		<span class="punctuation">{</span>
			<span data-toggle="tooltip" title="LiterateCS.HtmlGenerator"><a href="../LiterateCS/HtmlWeaver.html#LiterateCS.HtmlWeaver._generateHtml">_generateHtml</a></span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.HtmlGenerator.Execute(LiterateCS.BlockList, LiterateCS.SplitPath, LiterateCS.SplitPath)">.</span><span data-toggle="tooltip" title="LiterateCS.HtmlGenerator.Execute(LiterateCS.BlockList, LiterateCS.SplitPath, LiterateCS.SplitPath)"><a href="../LiterateCS/HtmlGenerator.html#LiterateCS.HtmlGenerator.Execute(LiterateCS.BlockList, LiterateCS.SplitPath, LiterateCS.SplitPath)">Execute</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="LiterateCS.Weaver.BlockListFromDocument(Microsoft.CodeAnalysis.Document)"><a href="../LiterateCS/Weaver.html#LiterateCS.Weaver.BlockListFromDocument(Microsoft.CodeAnalysis.Document)">BlockListFromDocument</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="Microsoft.CodeAnalysis.Document">document</span><span class="punctuation">)</span><span class="punctuation">,</span> <span data-toggle="tooltip" title="LiterateCS.SplitPath">codeFile</span><span class="punctuation">,</span> 
				<span data-toggle="tooltip" title="LiterateCS.Weaver.CreateOutputPath(LiterateCS.SplitPath, string)"><a href="../LiterateCS/Weaver.html#LiterateCS.Weaver.CreateOutputPath(LiterateCS.SplitPath, string)">CreateOutputPath</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="LiterateCS.SplitPath">codeFile</span><span class="punctuation">,</span> <span class="string" data-toggle="tooltip" title="string">&quot;.html&quot;</span><span class="punctuation">)</span><span class="punctuation">)</span><span class="punctuation">;</span>
		<span class="punctuation">}</span>

		<span class="keyword" id="LiterateCS.HtmlWeaver.WeaveFromMarkdown(LiterateCS.SplitPath)" data-toggle="tooltip" title="LiterateCS.HtmlWeaver.WeaveFromMarkdown(LiterateCS.SplitPath)">private</span> <span class="keyword" data-toggle="tooltip" title="void">void</span> <span data-toggle="tooltip" title="LiterateCS.HtmlWeaver.WeaveFromMarkdown(LiterateCS.SplitPath)">WeaveFromMarkdown</span> <span class="punctuation">(</span><span class="typename" data-toggle="tooltip" title="LiterateCS.SplitPath"><a href="../LiterateCS/SplitPath.html#LiterateCS.SplitPath">SplitPath</a></span> mdFile<span class="punctuation">)</span>
		<span class="punctuation">{</span>
			<span data-toggle="tooltip" title="LiterateCS.HtmlGenerator"><a href="../LiterateCS/HtmlWeaver.html#LiterateCS.HtmlWeaver._generateHtml">_generateHtml</a></span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.HtmlGenerator.Execute(LiterateCS.BlockList, LiterateCS.SplitPath, LiterateCS.SplitPath)">.</span><span data-toggle="tooltip" title="LiterateCS.HtmlGenerator.Execute(LiterateCS.BlockList, LiterateCS.SplitPath, LiterateCS.SplitPath)"><a href="../LiterateCS/HtmlGenerator.html#LiterateCS.HtmlGenerator.Execute(LiterateCS.BlockList, LiterateCS.SplitPath, LiterateCS.SplitPath)">Execute</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="LiterateCS.Weaver.BlockListFromMarkdown(string)"><a href="../LiterateCS/Weaver.html#LiterateCS.Weaver.BlockListFromMarkdown(string)">BlockListFromMarkdown</a></span> <span class="punctuation">(</span><span class="punctuation" data-toggle="tooltip" title="string">!</span><span data-toggle="tooltip" title="LiterateCS.SplitPath">mdFile</span><span class="punctuation">)</span><span class="punctuation">,</span> <span data-toggle="tooltip" title="LiterateCS.SplitPath">mdFile</span><span class="punctuation">,</span>
				<span data-toggle="tooltip" title="LiterateCS.Weaver.CreateOutputPath(LiterateCS.SplitPath, string)"><a href="../LiterateCS/Weaver.html#LiterateCS.Weaver.CreateOutputPath(LiterateCS.SplitPath, string)">CreateOutputPath</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="LiterateCS.SplitPath">mdFile</span><span class="punctuation">,</span> <span class="string" data-toggle="tooltip" title="string">&quot;.html&quot;</span><span class="punctuation">)</span><span class="punctuation">)</span><span class="punctuation">;</span>
		<span class="punctuation">}</span>
</code></pre>
<h2 id="loading-defaults">Loading Defaults</h2>
<p>To load the default front matter we call the <code>ParseFrontMatter</code> method in the
HTML generator.</p>
<pre class="csharp"><code class="csharp">		<span class="keyword" id="LiterateCS.HtmlWeaver.LoadDefaultFrontMatter()" data-toggle="tooltip" title="LiterateCS.HtmlWeaver.LoadDefaultFrontMatter()">private</span> <span class="keyword" data-toggle="tooltip" title="void">void</span> <span data-toggle="tooltip" title="LiterateCS.HtmlWeaver.LoadDefaultFrontMatter()">LoadDefaultFrontMatter</span> <span class="punctuation">(</span><span class="punctuation">)</span>
		<span class="punctuation">{</span>
			<span class="keyword" data-toggle="tooltip" title="string">var</span> <span id="defaults">defaults</span> <span class="punctuation">=</span> <span class="punctuation" data-toggle="tooltip" title="string">!</span><span data-toggle="tooltip" title="LiterateCS.Options"><a href="../LiterateCS/Weaver.html#LiterateCS.Weaver._options">_options</a></span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.SplitPath">.</span><span data-toggle="tooltip" title="LiterateCS.SplitPath"><a href="../LiterateCS/Options.html#LiterateCS.Options.InputPath">InputPath</a></span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.SplitPath.WithFile(string)">.</span><span data-toggle="tooltip" title="LiterateCS.SplitPath.WithFile(string)"><a href="../LiterateCS/SplitPath.html#LiterateCS.SplitPath.WithFile(string)">WithFile</a></span> <span class="punctuation">(</span><span class="typename" data-toggle="tooltip" title="LiterateCS.Options"><a href="../LiterateCS/Options.html#LiterateCS.Options">Options</a></span><span class="punctuation" data-toggle="tooltip" title="string">.</span><span data-toggle="tooltip" title="string"><a href="../LiterateCS/Options.html#LiterateCS.Options.DefaultsFile">DefaultsFile</a></span><span class="punctuation">)</span><span class="punctuation">;</span>
			<span class="keyword">if</span> <span class="punctuation">(</span><span class="typename" data-toggle="tooltip" title="System.IO.File">File</span><span class="punctuation" data-toggle="tooltip" title="System.IO.File.Exists(string)">.</span><span data-toggle="tooltip" title="System.IO.File.Exists(string)">Exists</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="string">defaults</span><span class="punctuation">)</span><span class="punctuation">)</span>
			<span class="punctuation">{</span>
				<span data-toggle="tooltip" title="LiterateCS.Weaver.ConsoleOut(string, params object[])"><a href="../LiterateCS/Weaver.html#LiterateCS.Weaver.ConsoleOut(string, object[])">ConsoleOut</a></span> <span class="punctuation">(</span><span class="string" data-toggle="tooltip" title="string">&quot;Reading default front matter from &#39;{0}&#39;&quot;</span><span class="punctuation">,</span> <span data-toggle="tooltip" title="string">defaults</span><span class="punctuation">)</span><span class="punctuation">;</span>
				<span data-toggle="tooltip" title="LiterateCS.HtmlGenerator"><a href="../LiterateCS/HtmlWeaver.html#LiterateCS.HtmlWeaver._generateHtml">_generateHtml</a></span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.HtmlGenerator.ParseFrontMatter(string, string)">.</span><span data-toggle="tooltip" title="LiterateCS.HtmlGenerator.ParseFrontMatter(string, string)"><a href="../LiterateCS/HtmlGenerator.html#LiterateCS.HtmlGenerator.ParseFrontMatter(string, string)">ParseFrontMatter</a></span> <span class="punctuation">(</span><span class="typename" data-toggle="tooltip" title="System.IO.File">File</span><span class="punctuation" data-toggle="tooltip" title="System.IO.File.ReadAllText(string)">.</span><span data-toggle="tooltip" title="System.IO.File.ReadAllText(string)">ReadAllText</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="string">defaults</span><span class="punctuation">)</span><span class="punctuation">,</span>
					<span data-toggle="tooltip" title="string">defaults</span><span class="punctuation">)</span><span class="punctuation">;</span>
			<span class="punctuation">}</span>
		<span class="punctuation">}</span>
</code></pre>
<h2 id="toc-management">TOC Management</h2>
<p>Loading and updating table of contents is handled by the
<a href="TocManager.html">TocManager</a> class. We can add new entries to
TOC using the <code>AddToToc</code>method. Updating is performed only, if
<code>-u</code> switch is specified in the options.</p>
<pre class="csharp"><code class="csharp">		<span class="keyword" id="LiterateCS.HtmlWeaver.LoadToc()" data-toggle="tooltip" title="LiterateCS.HtmlWeaver.LoadToc()">private</span> <span class="keyword" data-toggle="tooltip" title="void">void</span> <span data-toggle="tooltip" title="LiterateCS.HtmlWeaver.LoadToc()">LoadToc</span> <span class="punctuation">(</span><span class="punctuation">)</span>
		<span class="punctuation">{</span>
			<span class="keyword" data-toggle="tooltip" title="string">var</span> <span id="tocFile">tocFile</span> <span class="punctuation">=</span> <span class="punctuation" data-toggle="tooltip" title="string">!</span><span data-toggle="tooltip" title="LiterateCS.Options"><a href="../LiterateCS/Weaver.html#LiterateCS.Weaver._options">_options</a></span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.SplitPath">.</span><span data-toggle="tooltip" title="LiterateCS.SplitPath"><a href="../LiterateCS/Options.html#LiterateCS.Options.InputPath">InputPath</a></span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.SplitPath.WithFile(string)">.</span><span data-toggle="tooltip" title="LiterateCS.SplitPath.WithFile(string)"><a href="../LiterateCS/SplitPath.html#LiterateCS.SplitPath.WithFile(string)">WithFile</a></span> <span class="punctuation">(</span><span class="typename" data-toggle="tooltip" title="LiterateCS.Options"><a href="../LiterateCS/Options.html#LiterateCS.Options">Options</a></span><span class="punctuation" data-toggle="tooltip" title="string">.</span><span data-toggle="tooltip" title="string"><a href="../LiterateCS/Options.html#LiterateCS.Options.TocFile">TocFile</a></span><span class="punctuation">)</span><span class="punctuation">;</span>
			<span class="keyword">if</span> <span class="punctuation">(</span><span class="typename" data-toggle="tooltip" title="System.IO.File">File</span><span class="punctuation" data-toggle="tooltip" title="System.IO.File.Exists(string)">.</span><span data-toggle="tooltip" title="System.IO.File.Exists(string)">Exists</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="string">tocFile</span><span class="punctuation">)</span><span class="punctuation">)</span>
			<span class="punctuation">{</span>
				<span data-toggle="tooltip" title="LiterateCS.Weaver.ConsoleOut(string, params object[])"><a href="../LiterateCS/Weaver.html#LiterateCS.Weaver.ConsoleOut(string, object[])">ConsoleOut</a></span> <span class="punctuation">(</span><span class="string" data-toggle="tooltip" title="string">&quot;Reading TOC from file &#39;{0}&#39;&quot;</span><span class="punctuation">,</span> <span data-toggle="tooltip" title="string">tocFile</span><span class="punctuation">)</span><span class="punctuation">;</span>
				<span data-toggle="tooltip" title="LiterateCS.TocManager"><a href="../LiterateCS/HtmlWeaver.html#LiterateCS.HtmlWeaver._tocManager">_tocManager</a></span> <span class="punctuation" data-toggle="tooltip" title="LiterateCS.TocManager">=</span> <span class="typename" data-toggle="tooltip" title="LiterateCS.TocManager"><a href="../LiterateCS/TocManager.html#LiterateCS.TocManager">TocManager</a></span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.TocManager.Load(string)">.</span><span data-toggle="tooltip" title="LiterateCS.TocManager.Load(string)"><a href="../LiterateCS/TocManager.html#LiterateCS.TocManager.Load(string)">Load</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="string">tocFile</span><span class="punctuation">)</span><span class="punctuation">;</span>
			<span class="punctuation">}</span>
			<span class="keyword">else</span>
				<span data-toggle="tooltip" title="LiterateCS.TocManager"><a href="../LiterateCS/HtmlWeaver.html#LiterateCS.HtmlWeaver._tocManager">_tocManager</a></span> <span class="punctuation" data-toggle="tooltip" title="LiterateCS.TocManager">=</span> <span class="keyword" data-toggle="tooltip" title="LiterateCS.TocManager">new</span> <span class="typename"><a href="../LiterateCS/TocManager.html#LiterateCS.TocManager">TocManager</a></span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
		<span class="punctuation">}</span>

		<span class="keyword" id="LiterateCS.HtmlWeaver.AddToToc(LiterateCS.SplitPath)" data-toggle="tooltip" title="LiterateCS.HtmlWeaver.AddToToc(LiterateCS.SplitPath)">private</span> <span class="keyword" data-toggle="tooltip" title="void">void</span> <span data-toggle="tooltip" title="LiterateCS.HtmlWeaver.AddToToc(LiterateCS.SplitPath)">AddToToc</span> <span class="punctuation">(</span><span class="typename" data-toggle="tooltip" title="LiterateCS.SplitPath"><a href="../LiterateCS/SplitPath.html#LiterateCS.SplitPath">SplitPath</a></span> path<span class="punctuation">)</span>
		<span class="punctuation">{</span>
			<span class="keyword">if</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="LiterateCS.Options"><a href="../LiterateCS/Weaver.html#LiterateCS.Weaver._options">_options</a></span><span class="punctuation" data-toggle="tooltip" title="bool">.</span><span data-toggle="tooltip" title="bool"><a href="../LiterateCS/Options.html#LiterateCS.Options.UpdateToc">UpdateToc</a></span><span class="punctuation">)</span>
				<span data-toggle="tooltip" title="LiterateCS.TocManager"><a href="../LiterateCS/HtmlWeaver.html#LiterateCS.HtmlWeaver._tocManager">_tocManager</a></span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.TocManager.AddToToc(LiterateCS.SplitPath)">.</span><span data-toggle="tooltip" title="LiterateCS.TocManager.AddToToc(LiterateCS.SplitPath)"><a href="../LiterateCS/TocManager.html#LiterateCS.TocManager.AddToToc(LiterateCS.SplitPath)">AddToToc</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="LiterateCS.SplitPath">path</span><span class="punctuation">)</span><span class="punctuation">;</span>
		<span class="punctuation">}</span>
	<span class="punctuation">}</span>
<span class="punctuation">}</span>
</code></pre>

				</div>
				<ul class="pager">
	<li class="previous"><a href="../LiterateCS/MdWeaver.html">Previous: Markdown Weaver</a></li>
	<li class="next"><a href="../LiterateCS/TocManager.html">Next: TOC Manager</a></li>
</ul>
			</div>
        </div>
    </div>
    
    <footer class="panel-footer text-center">
        <div align="center">Copyright © 2018 Tommi Johtela</div>
		<div align="right">
			<small>
				Documentation created with <a href="https://johtela.github.io/LiterateCS/">LiterateCS</a>.
			</small>
		</div>
    </footer>


    
    <script src="../bootstrap/js/jquery.min.js"></script>
    <script src="../bootstrap/js/bootstrap.min.js"></script>
    <script src="../sidebar/sidebar.js"></script>
    <script src="../syntax-highlight/syntax.js"></script>
    <script type="text/x-mathjax-config">
        MathJax.Hub.Config({
        extensions: ["jsMath2jax.js"]
        });
    </script>
    <script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_HTML'></script>
	<script src="../mermaid/mermaid.min.js"></script>
	<script>mermaid.initialize({startOnLoad:true});</script>

</body>
</html>